<?php
namespace app\manage\controller;

class AuditCpInfo extends Base
{
    //CP对账列表
    public function index(){
        if(request()->isAjax()){
            $page = input('page');
            $limit = input('limit');
            $id = input('id');
            $gameId = input('game_id');

            $where = [];
            !empty($id) && $where['id'] = $id;
            !empty($gameId) && $where['game_id'] = $gameId;

            if( ! $count=model('ViewGameManage')->where($where)->count() ){
               $this->layTable();
            }

            $data = model('ViewGameManage')
                ->field('game_id, game_name, channel_rate, pay_rate, pay_rate_private')
                ->where($where)
                ->order('game_id desc')
                ->limit(($page-1)*$limit, $limit)
                ->select();

            $this->layTable(0, 'CP转账信息', $data, $count);
        }else{
            return view();
        }
    }

    //编辑
    public function edit(){
        model('GameExtend')->save(input(), ['game_id', input('game_id')]) ? $this->layJson(0, '编辑成功') : $this->layJson(1, '编辑失败，请重试');
    }
}